﻿using System;
using System.Windows.Forms;
using POS.BusinessComponents;
using POS.BusinessEntities;
using POS.UI.UserControls;

namespace POS.UI.Mantenimientos
{
    public partial class BusquedaArticuloForm : Form, IBusquedaForm
    {
        #region Constructors

        private BusquedaArticuloForm()
        {
            InitializeComponent();
        }

        public BusquedaArticuloForm(string filter, SearchField searchField)
            : this()
        {
            this.filter = filter;
            searchBy = searchField;
        }

        #endregion
        
        #region Declarations

        private readonly string filter;
        private readonly SearchField searchBy;

        //private const int ColId = 0;
        //private const int ColName = 1;
        //private const int ColMargen = 2;
        //private const int ColPrecio = 3;
        //private const int ColImpuesto = 4;
        //private const int ColPrecioImp = 5;

        #endregion

        #region Properties: Public

        public int SelectedId { get; set; }
        public string SelectedCode { get; set; }
        public string SelectedName { get; set; }

        #endregion


        #region Event Handlers
        
        private void BusquedaArticuloForm_Load(object sender, EventArgs e)
        {
            filterTextBox.Text = filter;
            if (searchBy == SearchField.Name)
                nameRadioButton.Checked = true;
            else if (searchBy == SearchField.Code)
                codeRadioButton.Checked = true;
            
            buscarButton.PerformClick();

            //dataGrid.Columns[columnaId].Visible = false;
            //dataGrid.Columns[columnaNombre].Width = 100;
            //dataGrid.Columns[columnaNombre].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
        }

        private void AceptarButton_Click(object sender, EventArgs e)
        {

        }

        //private void dataGrid_KeyPress(object sender, KeyPressEventArgs e)
        //{

        //}

        //private void dataGrid_MouseDoubleClick(object sender, MouseEventArgs e)
        //{

        //}

        private void buscarButton_Click(object sender, EventArgs e)
        {
            //var results = new BCArticulo().GetList(filtroTextBox.Text.Trim());
            //dataGrid.DataSource = results;
            dataGrid.Focus();    
        }
        
        //private void filtroTextBox_KeyPress(object sender, KeyPressEventArgs e)
        //{

        //}

        #endregion

        
    }
}
